import { defineAsyncComponent } from 'vue'

const formName: any = import.meta.glob('./form/*.vue', { eager: true })
const formComponent = import.meta.glob('./form/*.vue')

const regionName: any = import.meta.glob('./region/*.vue', { eager: true })
const regionComponent = import.meta.glob('./region/*.vue')

export default function (app) {
  for (const [key, value] of Object.entries(formComponent)) {
    // 注册组件名字   没有抛出Name， 引用文件组件文件夹名字<>
    const name = formName[key].default.name || key.slice(31, key.lastIndexOf('/'))
    if (name.includes('jRow')) continue
    app.component(name, defineAsyncComponent(value))
  }

  for (const [key, value] of Object.entries(regionComponent)) {
    // 注册组件名字   没有抛出Name， 引用文件组件文件夹名字<>
    const name = regionName[key].default.name || key.slice(31, key.lastIndexOf('/'))
    if (name.includes('jRow')) continue
    app.component(name, defineAsyncComponent(value))
    console.log(name + '---' + value)
  }
}
